package com.cxy.controller.admin;

import com.cxy.dto.ListRateDTO;
import com.cxy.entity.ListRate;
import com.cxy.result.Result;
import com.cxy.service.ListRateService;
import com.cxy.vo.ListRateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(tags = "榜单评级")
@RestController
@RequestMapping("/listRate")
@Slf4j
public class ListRateController {

    @Autowired
    private ListRateService listRateService;
    /**
     * 返回榜单评级
     */
    @ApiOperation("返回榜单评级")
    @GetMapping("/all")
    public Result<List<ListRateVO>> selectAll(){
       List<ListRateVO> listRateVO = listRateService.selectAll();
       return Result.success(listRateVO);
    }
    /**
     * 根据id查询榜单评级
     */
    @ApiOperation("根据id查询榜单评级")
    @GetMapping("/listRate/{id}")
    public Result<ListRate> getById(@PathVariable Long id){
        ListRate listRate = listRateService.getById(id);
        return Result.success(listRate);
    }
    /**
     * 修改榜单评级
     */
    @ApiOperation("修改榜单评级")
    @PutMapping("/update")
    public Result update(@RequestBody ListRateDTO listRateDTO){
        listRateService.update(listRateDTO);
        return Result.success();
    }
}

